package io.renren.modules.app.controller;


import io.renren.common.result.Result;
import io.renren.modules.medical.service.PatientDiseaseInformationService;
import io.renren.modules.medical.service.PatientDoctorRelativeService;
import io.renren.modules.medical.vo.medicalVo.DiseaseInfoDetailVo;
import io.renren.modules.medical.vo.medicalVo.IllSubTitleAndIdVo;
import io.renren.modules.medical.vo.weixinVo.ApiDiseaseListVo;
import io.renren.modules.medical.vo.weixinVo.ApiMedicationRecord;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Luo Sheng
 * @school YiBin university
 * @create 2023-05-23 20:55
 */
@RestController
@RequestMapping("/app/patientBasicInfo")
@RequiredArgsConstructor
public class PatientBasicInformationApi {
    private final PatientDoctorRelativeService patientDoctorRelativeService;

    @Autowired
    private PatientDiseaseInformationService patientDiseaseInformationService;

    /**
     * 获取到该病人所有病情分类
     * @return
     */
    @GetMapping("/illSub")
    public Result<List<IllSubTitleAndIdVo>> patientIllSub(){
        List<IllSubTitleAndIdVo> illSubList = patientDoctorRelativeService.getPatientIllSub();
        return Result.success(illSubList);
    }

    @GetMapping("/diseaseList/{subId}")
    public Result<List<ApiDiseaseListVo>> diseaseList(@PathVariable("subId") Long subId){
        List<ApiDiseaseListVo> diseaseListVos = patientDiseaseInformationService.diseaseList(subId);
        return Result.success(diseaseListVos);
    }

    @GetMapping("/diseaseInfo/{diseaseId}")
    public Result<DiseaseInfoDetailVo> diseaseInfo(@PathVariable("diseaseId") Long diseaseId){
        DiseaseInfoDetailVo diseaseInfoDetailVo = patientDiseaseInformationService.getDiseaseDetailInfo(diseaseId);
        return Result.success(diseaseInfoDetailVo);
    }

    /**
     * 根据subId查询到所有的koa用药记录和治疗用药记录
     */
    @GetMapping("/medicationRecord/{subId}")
    public Result<ApiMedicationRecord> getMedicationRecord(@PathVariable Long subId){
        ApiMedicationRecord medicationRecord = patientDiseaseInformationService.getMedicationRecord(subId);
        return Result.success(medicationRecord);
    }

}
